<template>
  <div>
    <Header></Header>
    <Banner></Banner>
    <div class="main">
      <div class="main-left">
        <li @click="$router.push('/wz')" v-if="this.author == 2">
          <i class="iconfont icon-all-wenzhang"></i>
          我的文章
        </li>
        <li class="active" @click="$router.push('/sc')">
          <i class="iconfont icon-all-xiangqu"></i>
          我的关注
        </li>
        <li @click="$router.push('/wd')">
          <i class="iconfont icon-all-wendabangzhu"></i>
          我的问答
        </li>
        <li @click="$router.push('/pl')">
          <i class="iconfont icon-all-pinglun"></i>
          我的评论
        </li>
        <li @click="$router.push('/dy')">
          <i class="iconfont icon-all-yonghuming"></i>
          我的订阅
        </li>
        <li @click="$router.push('/ds')">
          <i class="iconfont icon-all-qian"></i>
          我的打赏
        </li>
        <li @click="$router.push('/tz')">
          <i class="iconfont icon-all-tongzhi"></i>
          通知中心
        </li>
        <li @click="$router.push('/ll')">
          <i class="iconfont icon-all-liulan"></i>
          浏览记录
        </li>
        <li @click="$router.push('/sz')">
          <i class="iconfont icon-all-icon_setting"></i>
          资料设置
        </li>
      </div>
      <div class="main-right">
        <div class="nav">
          <span v-bind:class="{ active1: isActive1}" @click="wz">我的关注的文章（{{articleCount}}）</span>
          <span v-bind:class="{ active2: isActive2}" @click="mm">我的关注的秘密（1）</span>
          <span v-bind:class="{ active3: isActive3}" @click="wd">我的关注的问题（{{questionCount}}）</span>
          <span v-bind:class="{ active4: isActive4}" @click="hf">我的关注的回复（1）</span>
        </div>
        <div class="content" v-if="article">
          <div
            style="text-align: center; font-size:16px;padding-top:10px;"
            v-if="this.articleList.length==0"
          >您还没有关注文章</div>
          <div class="search" v-if="this.articleList.length>0">
            <i class="iconfont icon-all-sousuo1"></i>
            <input type="text" placeholder="搜索您关注的文章">
          </div>
          <div class="content-item" v-if="this.articleList.length>0">
            <span class="content-tip">在线职业资格认证培训MRD</span>
            <span>
              <i class="iconfont icon-all-tubiao-"></i>
              2018/12/20
              <i
                class="iconfont icon-all-shanchu"
                style="color:red; padding-left:10px"
              ></i>
            </span>
          </div>
          <div class="more" v-if="questionCount>10">
            <button @click="getMoreQ(type=2)">加载更多</button>
          </div>
        </div>
        <div class="content" v-if="secret">
          <div class="search">
            <i class="iconfont icon-all-sousuo1"></i>
            <input type="text" placeholder="搜索您关注的秘密">
          </div>
          <div class="content-item">
            <span class="content-tip">在线职业资格认证培训MRD</span>
            <span>
              <i class="iconfont icon-all-tubiao-"></i>
              2018/12/20
              <i
                class="iconfont icon-all-shanchu"
                style="color:red; padding-left:10px"
              ></i>
            </span>
          </div>
          <div class="content-item">
            <span>在线职业资格认证培训MRD</span>
            <span>
              <i class="iconfont icon-all-tubiao-"></i>
              2018/12/20
              <i
                class="iconfont icon-all-shanchu"
                style="color:red; padding-left:10px"
              ></i>
            </span>
          </div>
          <div class="more" v-if="questionCount>10">
            <button @click="getMoreQ(type=3)">加载更多</button>
          </div>
        </div>
        <div class="content" v-if="question">
          <div
            style="text-align: center; font-size:16px;padding-top:10px;"
            v-if="this.questionList.length==0"
          >您还任何关注问题</div>
          <div class="search" v-if="this.questionList.length>0">
            <i class="iconfont icon-all-sousuo1"></i>
            <input type="text" placeholder="搜索您关注的问题">
          </div>
          <div v-if="this.questionList.length>0">
            <div class="content-item" v-for="(item,index) in questionList" :key="index">
              <span class="content-tip" @click="goQuestion(item)">{{item.title}}</span>
              <span>
                <i class="iconfont icon-all-tubiao-"></i>
                {{item.add_time}}
                <i
                  class="iconfont icon-all-shanchu"
                  style="color:red; padding-left:10px;cursor: pointer;"
                  @click="cancelQ(item)"
                ></i>
              </span>
            </div>
          </div>
          <div class="more" v-if="questionCount>10">
            <button @click="getMoreQ(type=1)">加载更多</button>
          </div>
        </div>
        <div class="content" v-if="reply">
          <div class="search">
            <i class="iconfont icon-all-sousuo1"></i>
            <input type="text" placeholder="搜索您关注的回复">
          </div>
          <div class="content-item">
            <span class="content-tip">在线职业资格认证培训MRD</span>
            <span>
              <i class="iconfont icon-all-tubiao-"></i>
              2018/12/20
              <i
                class="iconfont icon-all-shanchu"
                style="color:red; padding-left:10px"
              ></i>
            </span>
          </div>
          <div class="content-item">
            <span>在线职业资格认证培训MRD</span>
            <span>
              <i class="iconfont icon-all-tubiao-"></i>
              2018/12/20
              <i
                class="iconfont icon-all-shanchu"
                style="color:red; padding-left:10px"
              ></i>
            </span>
          </div>
          <div class="more" v-if="questionCount>10">
            <button @click="getMoreQ(type=5)">加载更多</button>
          </div>
        </div>
      </div>
    </div>
    <Footer></Footer>
  </div>
</template>

<script>
import Header from "@/common/Header/Header";
import Banner from "@/common/Banner/Banner";
import Footer from "@/common/Footer/Footer";
import qs from "qs";
export default {
  name: "sc",
  data() {
    return {
      no: false,
      isActive1: true,
      isActive2: false,
      isActive3: false,
      isActive4: false,
      article: true,
      secret: false,
      question: false,
      reply: false,
      articleList: [],
      secretList: [],
      questionList: [],
      replyList: [],
      sizeIndex: 10,
      articleCount: "",
      secretCount: "",
      questionCount: "",
      replyCount: "",
      author:"",
      // type : 2
    };
  },
  methods: {
    //文章
    wz() {
      this.isActive1 = true;
      this.isActive2 = false;
      this.isActive3 = false;
      this.isActive4 = false;
      this.article = true;
      this.secret = false;
      this.question = false;
      this.reply = false;
    },
    //问答
    wd(type =1) {
      this.type = type
      console.log(this.type)
      this.isActive1 = false;
      this.isActive2 = false;
      this.isActive3 = true;
      this.isActive4 = false;
      this.article = false;
      this.secret = false;
      this.question = true;
      this.reply = false;

    },
    //秘密
    mm() {
      
      this.isActive1 = false;
      this.isActive2 = true;
      this.isActive3 = false;
      this.isActive4 = false;
      this.article = false;
      this.secret = true;
      this.question = false;
      this.reply = false;

    },
    //回复
    hf() {
      this.isActive1 = false;
      this.isActive2 = false;
      this.isActive3 = false;
      this.isActive4 = true;
      this.article = false;
      this.secret = false;
      this.question = false;
      this.reply = true;
    },
    //获取所有的收藏
    getAllList() {
      this.$axios
        .get(
          "api/App/User/Set/web_user_attention_all?member_id=" +
            this.getCookie("member_id") +
            "&p=1&limit=" +
            this.sizeIndex +
            "&to_member_id=" +
            this.getCookie("member_id")
        )
        .then(res => {
          console.log(res);
          this.articleList = res.data.data.news_list.list;
          this.questionList = res.data.data.questions_list.list;
          this.articleCount = res.data.data.news_list.count;
          this.questionCount = res.data.data.questions_list.count;
        });
    },

    //删除问答关注
    cancelQ(item) {
      console.log(item);
      let param = {
        source_id: item.source_id,
        member_id: this.getCookie("member_id"),
        type: 1
      };
      this.$axios
        .post(
          "/api/App/User/Question/web_cancel_attentions",
          qs.stringify(param),
          {
            headers: { "Content-Type": "application/x-www-form-urlencoded" }
          }
        )
        .then(res => {
          // this.questionInfo.is_follower = 0;
          this.getAllList();
        });
    },
    //点击关注的问题 跳转到对应的页面
    goQuestion(item) {
      console.log(item);
      this.$router.push({
        path: "/replyQuestion",
        query: { questions_id: item.source_id }
      });
    },
    // 加载更多根据type 不同加载不同的类型
    getMoreQ(type){
      // if( type == 1){
      //   this.sizeIndex = this.sizeIndex + 10
      // } else {
      //   this.sizeIndex = 10
      //  this.sizeIndex = this.sizeIndex + 10
      // }
      // if( type == 2){
      //   this.sizeIndex = this.sizeIndex + 10
      // }
      // if( type == 3){
      //   this.sizeIndex = this.sizeIndex + 10
      // }
      // if( type == 5){
        
      // }
      this.sizeIndex = this.sizeIndex + 10
      // console.log(this.sizeIndex)
      // return;
      
      this.$axios
        .get(
          "api/App/User/Set/web_user_attention_question?member_id=" +
            this.getCookie("member_id") +
            "&p=1&limit=" +
            this.sizeIndex +
            "&to_member_id=" +
            this.getCookie("member_id") +"&type=" + type
        )
        .then(res => {
          if ( type == 1) {
            this.questionList = res.data.data.list; 
             console.log(this.questionList)
          }     
          if ( type == 2)  {
             this.articleList = res.data.data.list; 
             console.log(this.articleList)
          }  
          if ( type == 3)  {
            this.secretList = res.data.data.list;
            console.log(this.secretList) 
          }  
          // if (type == 5 )  {
          //    this.replyList = res.data.data.list; 
          //    console.log(this.replyList) 
          // }        
        });
    }
  },
  mounted(){
    this.author =this.getCookie("identity_type") 
  },
  created() {
    this.getAllList();
  },

  components: {
    Header,
    Banner,
    Footer
  }
};
</script>
<style lang="scss" scoped>
.main {
  width: 60%;
  height: auto;
  margin: 0 auto;
  margin-top: 30px;
  margin-bottom: 30px;
  display: flex;
  justify-content: space-between;
  .main-left {
    width: 230px;
    background-color: #fff;
    li {
      padding: 20px;
      list-style: none;
      border-left: 1px solid transparent;
      font-size: 18px;
      cursor: pointer;
    }
    .active {
      background-color: #f2f5fb;
      border-left: 1px solid #5079b7;
      color: #5079b7;
    }
  }
  .main-right {
    text-align: left;
    width: 900px;
    background-color: #fff;
    padding: 20px;
    margin-left: 30px;
    .nav {
      line-height: 1.8;
      border-bottom: 1px solid #5079b7;
      span {
        padding-bottom: 8px;
        display: inline-block;
        margin-right: 10px;
        cursor: pointer;
      }
      .active1 {
        border-bottom: 1px solid #5079b7;
        color: #5079b7;
      }
      .active2 {
        border-bottom: 1px solid #5079b7;
        color: #5079b7;
      }
      .active3 {
        border-bottom: 1px solid #5079b7;
        color: #5079b7;
      }
      .active4 {
        border-bottom: 1px solid #5079b7;
        color: #5079b7;
      }
      .money {
        margin-left: 325px;
      }
    }
    .content {
      .search {
        padding-left: 5px;
        input {
          border: none;
          outline: none;
          line-height: 30px;
        }
        input::-webkit-input-placeholder {
          color: #666;
          font-size: 12px;
          // padding-left: 10px;
          // letter-spacing: 2px;
        }
        input:-moz-placeholder {
          color: #666;
          font-size: 12px;
          // padding-left: 10px;
          // letter-spacing: 2px;
        }
        input:-ms-input-placeholder {
          color: #666;
          font-size: 12px;
          // padding-left: 10px;
          // letter-spacing: 2px;
        }
      }
      .content-item {
        margin-top: 10px;
        padding-bottom: 10px;
        padding-left: 5px;
        padding-right: 5px;
        display: flex;
        justify-content: space-between;
        border-bottom: 1px solid #999;
        .content-tip {
          display: block;
          width: 70%;
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
          cursor: pointer;
        }
      }
      .more {
        width: 100%;
        text-align: center;
        button {
          border-radius: 10px;
          border: 0;
          outline: none;
          background: linear-gradient(90deg, #00aeff, #3369e7);
          color: #fff;
          box-shadow: 0 2px 6px 0 rgba(51, 105, 231, 0.4);
          margin-top: 20px;
          cursor: pointer;
        }
      }
    }
  }
}
</style>


